package cn.edu.njust.alg.leetcode;

public class Leetcode_223_rectangle_area {

	public static int titleToNumber(String s) {
		int num = 0;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			num = 26 * num + (c - 'A' + 1);
		}
		return num;
	}

	public static int computeArea(int A, int B, int C, int D, int E, int F,
			int G, int H) {
		int area = (C-A)*(D-B)+(G-E)*(H-F);
		if (C <= E || A >= G) {
			return area;
		}
		if (D <= F || B >= H) {
			return area;
		}
		int k1, k2;
		if (A < E) {
			if (G > C) {
				k1 = C - E;
			} else {
				k1 = G - E;
			}
		} else {
			if (C > G) {
				k1 = G - A;
			} else {
				k1 = C - A;
			}
		}

		if (B < F) {
			if (H > D) {
				k2 = D - F;
			} else {
				k2 = H - F;
			}
		} else {
			if (D > H) {
				k2 = H - B;
			} else {
				k2 = D - B;
			}
		}

		return area-k1 * k2;
	}
	public static void main(String[] args) {

		System.out.println(titleToNumber("BA"));
	}

}
